<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>轮播图</title>
	<#include '/frame/version.html'>
	<#include '/frame/manage/include_css.html'>
	<#include '/frame/manage/include_js.html'>
	<#include '/frame/taglib.html'>
	<style>.imgSize{width:100px; height:50px;}</style>
</head>
<body id="nv_member" class="pg_CURMODULE">
<#assign current="menu_banner">
	<div id="wp" class="wp">
		<#include "/include/header.html"/>
		<div class="contentmanage">
			<div class="developer">
				<div class="tableContent">
				<#include "/include/left.html"/>
				<#include "/include/wxtop.html"/>
				<div class="content">
					<div class="cLine">
						<div class="pageNavigator">
							<a href='${basePath}/admin/banner/toadd' class='btnGrayS'><img src="${basePath}/images/text.png" class="vm" />新增图片</a>
							<div class="right">
								<form action="${basePath}/admin/banner/search" method="post" id="form_pagination">
								<input class="px" name="query" placeholder="输入标题检索" value="${query?default('')}" maxlength="100"/>
								<input type="submit" value="搜索" class='btnGreen'/>
								</form>	
							</div>
						</div>
						<div class="clr"></div>
					</div>
         			<div class="msgWrap">
	           			<table class="ListProduct Shallow_border_color" border="0" cellSpacing="0" cellPadding="0" width="100%">
		           			<thead>
		           				<tr valign="top">
		           					<th class="">缩略图</th>
		           					<th class="">图片标题</th>
		           					<th class="">状态</th>
		           					<th class="">有效期止</th>
		           					<th class="">添加时间</th>
		           					<th class="">优先级</th>
		           					<th class="">操作</th>
		        				</tr>
		       				</thead>
		       				<tbody>
		       					<#if page?exists>
		       					<#list page.recordList as bean>
								<tr>
									<td><img src="${basePath}${bean.imgUrl?default('')}" onclick="viewImg(this)" class="imgSize"/></td>
		  							<td>${bean.title?default('')}</td>
		  							<td id="vt-${bean.id?default(0)}" flag="${bean.isValid?default('')}"><#if bean.isValid==0>停用<#else>启用</#if></td>
		  							<td><#if bean.dueDate??>${bean.dueDate?string('yyyy-MM-dd')!}</#if></td>
		  							<td>${bean.createTime?string('yyyy-MM-dd')!}</td>
		  							<td>${bean.sort?default('')}</td>
		  							<td class="norightborder">
		  								<a href="${basePath}/admin/banner/toadd?bid=${bean.id?default('')}" title="编辑轮播图">编辑</a>
		  								<a href="javascript:void(0);" onclick="delItem('${bean.id?default(0)}');">删除</a>
		  								<a href="javascript:void(0);" onclick="setValid('${bean.id?default(0)}');" id="va-${bean.id?default(0)}"><#if bean.isValid==0>启用<#else>停用</#if></a>
		  							</td>
								</tr>
								</#list>
								</#if>
							</tbody>
						</table>
					</div>
			<#assign formUrl="${basePath}/admin/banner/index?">
			<#include "/include/pagination.html">
		</div>
		<div class="clr"></div>
	</div></div></div>
<!--底部--></div>
<#include "/include/footer.html"/>
<script type="text/javascript">
function delItem(id){
	layer.confirm("确定要删除此轮播图吗？"
			,{icon: 4, title:'确认信息'}
	,function(index){
		layer.close(index);
		window.location.href="${basePath}/admin/banner/del?id="+id;
	},function(index){
		layer.msg("您取消了删除操作");
		layer.close(index);
	});
}
function viewImg(imgDom){
	var path = $(imgDom).attr("src");
	if(!path||path==""){
		layer.alert("无图片预览!",{icon:0});
		return;
	}
	layer.open({
	    type: 1,
	    area: ['500px', '250px'],
	    title: false,
	    skin: 'layui-layer-nobg',
	    shadeClose: true,
	    content: '<p style="text-align: center;"><img src="'+path+'" alt="无法显示图片" style="width:100%;height:100%;" /></p>'
	});
}
//启用 停用
function setValid(id){
	var msg,isValid,validFlag,vtState,vaState;
	var vtid="vt-"+id,vaid="va-"+id;
	
	validFlag = $("#"+vtid).attr("flag");
	if(!validFlag||validFlag==""){
		layer.alert("无效数据，刷新重试",{icon:0});
		return;
	}

	if(validFlag==0){
		msg="您确定要启用此轮播图吗?";
		isValid = 1;
		vtState = "启用";
		vaState = "停用";
	}else{
		msg="您确定要停用此轮播图吗?";
		isValid = 0;
		vtState = "停用";
		vaState = "启用";
	}
	
	layer.confirm(msg,{icon: 4, title:'确认信息'},
		function(index){
			layer.close(index);
			$.ajax({
	             type: "POST",
	             url: "${basePath}/admin/banner/setValid",
	             data: {isValid:isValid,id:id},
	             dataType: "json",
	             success: function(data){
	            	 if(data.success==true){
	            		 layer.msg("修改成功");
	            		 $("#"+vaid).text(vaState);
	            		 $("#"+vtid).text(vtState);
	            		 $("#"+vtid).attr("flag",isValid);
	            	 }else{
	            		 layer.msg("修改失败");
	            	 }
	             }
	         });
		},function(index){
			layer.msg("您取消了操作");
			layer.close(index);
		});
}
</script>
</body>
</html>